

<template>
  <div style="display: inline-block;margin-left: 12px">
    <el-button type="primary" size="small" @click="goEdit">编辑</el-button>
    <el-drawer
        title="编辑字典"
        size="450px"
        :destroy-on-close="true"
        :visible.sync="dialogVisible">
      <dictForm ref="dictForm"></dictForm>
      <div class="btnBox flex-center">
        <el-button type="primary" @click="submit">确 定</el-button>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import dictForm from "@/views/systemManage/dict/module/dictForm";
export default {
  name: "editDictBtnDrawer",
  props:{
    params:{
      default:()=>{}
    }
  },
  components:{
    dictForm
  },
  methods:{
    goEdit(){
      this.dialogVisible = true
      this.$api.getDicDetail({id:this.params.id}).then(res=>{
        this.$refs.dictForm.setData(res.data)
      })
    },
    submit() {
      this.$refs.dictForm.validate().then((res) => {
        let params = {
          "dicDisplay": this.$refs.dictForm.form.dicDisplay,
          "dicParentId": this.$refs.dictForm.form.dicParentId,
          "dicValue": this.$refs.dictForm.form.dicValue,
          "id": this.params.id
        }
        this.$api.editDics(params).then(res => {
          this.$message.success('编辑成功')
          this.dialogVisible = false
          this.$emit('after-op')
        })
      });
    },
  },
  data(){
    return {
      dialogVisible:false
    }
  },
}
</script>

<style scoped>

</style>